/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
function windLast24Hours() {
        var datatbl = new google.visualization.DataTable();
        //get the data from the file and load it into the google datatable
    $.getJSON('/fetchData.php?data={Fields:WindSpeed,WindDirection|Sort:Date,Ascending|Interval:1}', function(data) {

             var noElements = data.length;
//             datatbl.addColumn('string', 'Date');
             datatbl.addColumn('number', 'Wind Direction');
             datatbl.addColumn('number', 'Wind Speed');
	     datatbl.addColumn({type:'string', role:'tooltip'});
             datatbl.addRows(noElements);
        
        //Put the data into the datatable
        $.each(data, function(i, v) {
            // set the values for both the name and the population
            
  //          datatbl.setValue(i, 0, v.Date.substr(10));
  //
            var rads = 0.0174532925;
            x = v.WindSpeed * Math.cos(v.WindDirection * rads);
            y = v.WindSpeed * Math.sin(v.WindDirection * rads);
            datatbl.setValue(i, 0, y);
            datatbl.setValue(i, 1, x);
	     datatbl.setValue(i, 2, "Speed: " + v.WindSpeed + ", Direction:" + v.WindDirection);
//              datatbl.addrows([y, x, "Tool Tip"]);           
        });

        var options = {
          title: 'Todays Wind Speed',
       //hxis: {title: 'Speed', minValue: 0, maxValue: 100},
  //        vAxis: {title: 'Direction', minValue: 0, maxValue: 30},
          curveType: 'function',
          legend: 'none',
//          lineWidth: 2,
//          pointSize: 1

          
        };

    //declare the chart (which is a table) and draw it 
    var chart = new google.visualization.ScatterChart(document.getElementById('graph_wind_24_hours_div'));
        chart.draw(datatbl, options);
      });
}

